from django.db import models

from api.utils.enums import PriceType


class StockRecord(models.Model):
    product = models.ForeignKey("Porduct", on_delete=models.CASCADE, related_name="stock_record")
    num_in_stock = models.IntegerField("库存数量", default=0)
    num_allocated = models.IntegerField("分配数量", default=0)


class StockPrice(models.Model):
    type = models.CharField(
        "支付类型", choices=PriceType.to_choices(), default=PriceType.RMB.value, max_length=64
    )
    price = models.PositiveIntegerField("支付额度", default=0)
    stock_record = models.ForeignKey("StockRecord", on_delete=models.CASCADE, related_name="price")
